package com.risenb.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import com.risenb.bean.Menu;

public interface MenuMapper {
	
    int removeMenuById(Integer id);

    int createMenu(Menu record);

    Menu queryMenuById(Integer id);

    int modifyMenuById(Menu record);

    @Select("select * from menus")
    @ResultType(Menu.class)
    List<Menu> queryMenus();
    
    @Select("select * from menus where parentid = #{parentid,jdbcType=INTEGER} order by createtime desc")
    @ResultType(Menu.class)
    List<Menu> queryMenusByParentid(@Param("parentid")Integer parentid);
    
    //批量删除
    @Delete("delete from menus where id in(${ids})")
    int removeMenuByIds(@Param("ids")String ids);
    
    @Select("select * from menus where FIND_IN_SET(id,findMenuByParentId(#{ids}))")
    List<Menu> queryMenusByParentidRecur(@Param("ids")String ids);
    
}